package input;

import java.io.*;

//缓冲流加自定义数组,效率比较高
public class FileInputStreamDemo7 {
    public static void main(String[] args) throws IOException {
        long start=System.currentTimeMillis();
        copyFile();
        long end=System.currentTimeMillis();
        System.out.println("缓冲流加自定义数组耗时"+(end-start)+"毫秒");
    }
    public static void copyFile() throws IOException {
        BufferedOutputStream bos=new BufferedOutputStream(new FileOutputStream("G:\\\\Javatest2\\\\input\\\\image.jpg"));
        BufferedInputStream bis=new BufferedInputStream(new FileInputStream("G:\\Javatest2\\file\\image.jpg"));
        int len;
        byte[] bys=new byte[8192];
        while((len=bis.read(bys))!=-1){
            bos.write(bys,0,len);
        }
        bis.close();
        bos.close();
    }
}
